package com.p1;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("/hello")
public class HelloController {

    //像这种在类和方法上都有路径的话,真实的访问路径为:localhost:8080//hello/h1,一般都只写在方法名上
    @RequestMapping("/h1")
    public String hello(Model model){
        //封装数据
        model.addAttribute("msg","hello,SpringMVC");
        return "hello";//会被视图层解析,拼接成hello.jsp,找到我们的前端页面
    }
}
